#include <stdio.h>
#include <string.h>
#define NSIZE 8
/***********文本文件转二进制**********/
void Text2Bin(const char *sIn, const char *sOut)
{
    char a[255];
    int count = 0;
    int ch;
    for (int j = 0; j < 255; j++)
        a[j] = '\0';
    FILE *fin = fopen(sIn, "r");
    FILE *fout = fopen(sOut, "w");
    for (int i = 0; i <= 255; i++)
        fscanf(fin, "%c", &a[i]);
    for (int k = 0; k <= 254 && a[k] != '\0'; k++)
    {
        ch = a[k];
        for (int a = 7; a >= 0; a--)
            fprintf(fout, "%d", ch >> a & 1);
        //fprintf(fout,"\n");
    }
    fclose(fin);
    fclose(fout);
}
int main(int argc, char *argv[]){
  Text2Bin(argv[1]);
  printf("\nSuccessfully converted file!\n");
  return 0;
}